package hyit.app.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.List;

import hyit.app.dao.IGpsLocationDAO;
import hyit.app.model.GpsLocation;

public class GpsLocationDAOImpl implements IGpsLocationDAO {
	private Connection conn = null;
	private PreparedStatement pstmt = null;

	public GpsLocationDAOImpl(Connection conn) {
		this.conn = conn;
	}

	@Override
	public boolean doCreate(GpsLocation gps) throws Exception {
		boolean flag = false;
		String sql = "INSERT INTO gpslocation VALUES(NULL,?,?,?,?)";
		this.pstmt = this.conn.prepareStatement(sql);
		this.pstmt.setInt(1, gps.getTeacherNumber());
		this.pstmt.setString(2, gps.getLongitude());
		this.pstmt.setString(3, gps.getLatitude());
		this.pstmt.setTimestamp(4, gps.getDate());
		if (this.pstmt.executeUpdate() > 0) {
			flag = true;
		}
		this.pstmt.close();
		return flag;
	}

	@Override
	public GpsLocation getById(Integer id) throws Exception {
		return null;
	}

	@Override
	public List<GpsLocation> getByTeacherNumber(Integer number)
			throws Exception {
		return null;
	}

}
